<template>
  <div class="the-carousel">
    <a-carousel arrows>
      <template #prevArrow>
        <div
          class="custom-slick-arrow"
          style="left: 10px; z-index: 1"
        >
          <left-circle-outlined />
        </div>
      </template>
      <template #nextArrow>
        <div
          class="custom-slick-arrow"
          style="right: 10px"
        >
          <right-circle-outlined />
        </div>
      </template>
      <div
        v-for="(item, index) in data"
        :key="index"
        class="carousel-node"
      >
        <div :style="item.style">
          <a-row>
            <a-col
              v-if="index%2!=0"
              :class="index%2==0 ? 'item-right' : 'item-left'"
            >
              <img
                v-if="item.sourceUrl"
                :src="item.sourceUrl"
                :alt="item.title"
                @click="clickItem(item)"
              />
            </a-col>
            <a-col :class="index%2==0 ? 'item-left' : 'item-right'">
              <h1 @click="clickItem(item)">{{item.title}}</h1>
              <p>{{item.description}}</p>
              <a-button
                type="link"
                @click="clickItem(item)"
                class="more-button"
              >更多</a-button>
            </a-col>
            <a-col
              v-if="index%2==0"
              :class="index%2==0 ? 'item-right' : 'item-left'"
            >
              <img
                v-if="item.sourceUrl"
                :src="item.sourceUrl"
                :alt="item.title"
                @click="clickItem(item)"
              />
            </a-col>
          </a-row>
        </div>
      </div>
    </a-carousel>
  </div>
</template>
<script>
import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
import { defineComponent } from 'vue';
export default defineComponent({
  components: {
    LeftCircleOutlined,
    RightCircleOutlined,
  },
  props:{
    data:{
      type:Array,
      default:()=>[]
    }
  },
  methods:{
    clickItem(item){
      this.$emit("clickItem",item)
    }
  }
});
</script>
<style lang="less" scoped>
/* For demo */
.ant-carousel :deep(.slick-slide) {
  text-align: center;
  // height: 90vh;
  width: 10vw;
  /* line-height: 160px; */
  // background: #364d79;
  overflow: hidden;
}

.ant-carousel :deep(.slick-arrow.custom-slick-arrow) {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  opacity: 0.3;
  z-index: 1;
}
.ant-carousel :deep(.custom-slick-arrow:before) {
  display: none;
}
.ant-carousel :deep(.custom-slick-arrow:hover) {
  opacity: 0.5;
}

// .ant-carousel :deep(.slick-slide h3) {
//   color: #fff;
// }

.the-carousel {
  text-align: center;
  height: 100vh;
  .carousel-node {
    text-align: center;
    vertical-align: middle;
    height: 100vh;
    .item-left {
      width: 50%;
      display: inline-block;
      h1 {
        margin-top: 150px;
        height: 100px;
        text-align: right;
      }
      p {
        text-align: left;
        width: 60%;
        font-size: 20px;
        margin-left: 40%;
      }
      img {
        height: 100vh;
        position: absolute;
        right: 0;
        margin-right: 100px;
      }
      .more-button {
        margin-left: 80%;
      }
    }
    .item-right {
      width: 50%;
      display: inline-block;
      h1 {
        margin-top: 150px;
        height: 100px;
        text-align: left;
      }
      p {
        text-align: left;
        width: 60%;
        font-size: 20px;
        margin-right: 40%;
      }
      img {
        margin-left: 100px;
        height: 100vh;
      }
      .more-button {
        margin-left: 20%;
      }
    }
  }
}
</style>